<?php
$this->breadcrumbs=array(
	
	'Пользователи',
);

$this->menu=array(
	array('label'=>'List User', 'url'=>array('index')),
	array('label'=>'Create User', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	
	$('.search-form').toggle();
	if ($('.search-button a').html()=='Показать') { 
		$('.search-button a').html('Скрыть'); 
	} else {
		$('.search-button a').html('Показать');
	}
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('user-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>




<div class="section">
		<div class="box">
		
			<div class="title">
				<h2>Поиск</h2>
				<span class="search-button" style="float:right; display:block; padding:0 10px;"><a href="#">Показать</a></span>
			</div>
			<div class="content search-form" style="display:none;">
				<?php $this->renderPartial('_search',array(
						'model'=>$model,
					)); ?>
			</div>

		</div>
</div>

<div class="section">
	<div class="box">
	
		<div class="title">
			<h2><?= Yii::t('app','Управление пользователями'); ?></h2>
			
		</div>
		
		<div class="content">
			<div class="button">	
			
				<a href="<?= $this->createUrl('create'); ?>" class="button green medium" style="opacity: 0.7; "><?= Yii::t('app', 'Добавить пользователя') ?></a>
				<a href="<?= $this->createUrl('/rights'); ?>" class="button green medium" style="opacity: 0.7; "><?= Yii::t('app', 'Права пользователей') ?></a>
			</div>
			
		<?php $this->widget('zii.widgets.grid.CGridView', array(
			'id'=>'user-grid',
			'dataProvider'=>$model->search(),
			//'filter'=>$model,
			'selectableRows'=>$model->count(),
			'ajaxUpdate'=>false,
			'itemsCssClass'=>'table',
			'columns'=>array(
				array(
		       'class'=>'CCheckBoxColumn',       
		    ),
				'id',
				'email',
				'nickname',
				array('name'=>'dateRegistered','value'=>'date("d/m/Y",strtotime($data->dateRegistered))'),

				array(
					'class'=>'CLinkColumn',
    			'header'=>'Проверен',
    			'labelExpression'=>'($data->confirmed==1) ? "<img src=".Yii::app()->baseUrl."/themes/".Yii::app()->theme->name."/images/status1.png />" : "<img src=".Yii::app()->baseUrl."/themes/".Yii::app()->theme->name."/images/status0.png width=9 />"',

		    ),
				/*
				'confirmCode',
				'lastname',
				'firstname',
				'middlename',
				'birthday',
				'city_id',
				'country_id',
				'phone',
				'profile',
				'address_street',
				'address_home',
				'address_corp',
				'address_flat',
				'address_code',
				'passport_s',
				'passport_n',
				'passport_issued',
				'passport_date',
				'balance',
				*/
				array(
					'class'=>'CButtonColumn',
					'template'=>'{update} {delete}',  		 
					'updateButtonImageUrl'=>$this->path.'gfx/icon-edit.png',
					'deleteButtonImageUrl'=>$this->path.'gfx/icon-delete.png',
					//'afterDelete'=>'function(link,success,data){ if(success) alert("Delete completed successfuly"); }',
				),
			),
		)); ?>
		</div>

	</div>
</div>